package com.sise.wangzhan.command;

import com.netflix.hystrix.HystrixCommand;
import com.netflix.hystrix.HystrixCommandGroupKey;
import com.netflix.hystrix.HystrixCommandProperties;

/**
 * @Classname MyCommand
 * @Description TODO
 * @Date 2020/4/29 17:32
 * @Created by wangzhan
 */
public class MyCommand extends HystrixCommand<String> {

    //设置超时时间为500毫秒
    public MyCommand() {
        super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("ExampleGrop"))
                .andCommandPropertiesDefaults(HystrixCommandProperties.Setter().withExecutionTimeoutInMilliseconds(500)));
    }

    @Override
    protected String run() throws Exception {

        //模拟超时
        Thread.sleep(800);
        return "";
    }

    @Override
    protected String getFallback(){
        return "";
    }
}
